package com.gavin.jelly;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.catalina.Session;

import com.google.code.kaptcha.Constants;

/**
 * Servlet implementation class code
 */
public class code extends HttpServlet {
	private static final long serialVersionUID = 1L;

	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		doPost(request, response);
	}

	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		response.setCharacterEncoding("UTF-8");
		response.setHeader("Content-type", "text/html;charset=UTF-8");
		HttpSession session = request.getSession();
		
		//这里获取session里面的验证码,必须要用idCode,详细请看ValidateCodeConfigHelper 这个接口的源码
		String str = (String) session.getAttribute("idCode");
		response.getWriter().write("验证码是:" + str);
		response.getWriter().write("<br/>");
		response.getWriter().write("<a href='./index.jsp'>返回</a>");
	}

}
